home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr34 / tarchiv.zip / TARCHIV.PAS < prev    next >
Pascal/Delphi Source File  |  1995-01-27  |  5KB  |  143 lines

  1. { TARCHIV.EXE }
  2.  
  3. { Andreas Schiffler, U of S, 1994 }
  4.  
  5. { This is the main tape-archiver program, which handles the command-line }
  6. { parameters and calls the TapeArchiver object. }
  7.  
  8. { Version history: }
  9. { ---------------- }
  10. { *** 1 May 1994                                                         }
  11. { 1.0B - original release of a beta-test version. Soon to be replaced by }
  12. {        definite version 1.0 after all the bugs have been found.        }
  13. { *** 2 June 1994                                                        }
  14. { 1.1B - added erase flag, longer timeout in ASPI, InfoLog flag          }
  15. {        Longflag for display, Fixed bug in Wildcard. Still testing.     }
  16. { *** 10 Dec 1994                             }
  17. { 1.2B - works fine up to now                         }
  18.  
  19. Program TArchiv;
  20.  
  21. Uses Dos, Arc, TapeArc, Toolbox;
  22.  
  23. { ====================== M A I N ============================ }
  24.  
  25. Const
  26.   Version = '1.2B';
  27.  
  28. Var
  29.   { Archiver object }
  30.   A       : PTapeArchiver;
  31.  
  32.   { Options }
  33.   ErrLogfn,
  34.   InfoLogfn : String;
  35.   Wordy     : Boolean;
  36.   Timeout   : Byte;
  37.   TapeType  : String;
  38.   DoTime    : Boolean;
  39.   DoReset   : Boolean;
  40.   DoErase   : Boolean;
  41.   LongFlag  : Boolean;
  42.   DoMem     : Boolean;
  43.  
  44.   { Local variables }
  45.   LineStr : String[80];
  46.   Count   : Byte;
  47.   EPos    : Byte;
  48.   Identifier,
  49.   Value   : String;
  50.   Result  : Integer;
  51.   PCode   : String[1];
  52.  
  53. Begin
  54.  { Title }
  55.  LineStr[0]:=#80;
  56.  FillChar(LineStr[1],80,196);
  57.  Writeln (' TRCHI ',Version,' - tape archiver program - A. Schiffler, U of S, 1994');
  58.  Write (LineStr);
  59.  { Helptext }
  60.  If ParamCount<3 Then Begin
  61.   Writeln ('Usage    : tarchiv a|x|l <LUN:save-set> <wildcard>|@<filelist> [<options>]');
  62.   Writeln ('           a  - to add files');
  63.   Writeln ('           x  - to extract files');
  64.   Writeln ('           l  - to list the directory');
  65.   Writeln ('LUN      : Local Unit Number of SCSI device = 0,1, ... ,7');
  66.   Writeln ('Saveset  : Saveset number to work with = 1,2, ...');
  67.   Writeln ('Wildcard : DOS wildcard, e.g. *.DAT, 1994????.DAT, ...');
  68.   Writeln ('Filelist : Filename of textfile containing filenames, one name per line');
  69.   Writeln ('Options  : syntax is IDENTIFIER=VALUE, use is optional');
  70.   Writeln ('           ERRLOG=<filename>  error-log textfile, default: screen');
  71.   Writeln ('           INFOLOG=<filename> info/files-log textfile, default: screen');
  72.   Writeln ('           WORDY=FALSE        suppresses informational text, default: TRUE');
  73.   Writeln ('           TIMEDISP=FALSE     suppresses time in error-log, default: TRUE');
  74.   Writeln ('           TIMEOUT=<number>   tape-timeout period in minutes, default: 15 min');
  75.   Writeln ('           TAPE=<tapetype>    type of tape for size, default: P6-120');
  76.   Writeln ('           RESET=TRUE         issue ASPI-reset at beginning, default: FALSE');
  77.   Writeln ('           ERASE=TRUE         erase tape from <saveset> to <end>, default: FALSE');
  78.   Writeln ('           LONG=FALSE         suppresses additional fileinfo, default: TRUE');
  79.   Writeln ('           SHOWMEM=TRUE       shows free memory for directory list, default: FALSE');
  80.   Writeln ('Tapetype : P5-15, P5-15, P5-30, P5-60, P5-90, P6-15, P6-35, P6-60, P6-90, P6-120');
  81.   Exit;
  82.  End;
  83.  { Set options to default values }
  84.  ErrLogfn := '';
  85.  InfoLogfn := '';
  86.  Wordy := True;
  87.  Timeout := 15;
  88.  TapeType := 'P6-120';
  89.  DoTime := True;
  90.  DoReset := False;
  91.  DoErase := False;
  92.  LongFlag := True;
  93.  DoMem := False;
  94.  { Determine user selected options }
  95.  If ParamCount>3 Then Begin
  96.   For Count := 4 To ParamCount Do Begin
  97.    EPos := Pos('=',ParamStr(Count));
  98.    If EPos>1 Then Begin
  99.     Identifier := Upper(Copy (ParamStr(Count),1,EPos-1));
  100.     Value := Upper(Copy (ParamStr(Count),EPos+1,Length(ParamStr(Count))-Length(Identifier)-1));
  101.     If (Identifier='ERRLOG') Then ErrLogfn := Value;
  102.     If (Identifier='INFOLOG') Then InfoLogfn := Value;
  103.     If (Identifier='WORDY') And (Value='FALSE') Then Wordy := False;
  104.     IF (Identifier='TIMEOUT') Then Val(Value,Timeout,Result);
  105.     IF (Identifier='TAPE') Then TapeType := Value;
  106.     IF (Identifier='TIMEDISP') AND (Value='FALSE') Then DoTime := False;
  107.     IF (Identifier='RESET') AND (Value='TRUE') Then DoReset := True;
  108.     IF (Identifier='ERASE') AND (Value='TRUE') Then DoErase := True;
  109.     IF (Identifier='LONG') AND (Value='FALSE') Then LongFlag := False;
  110.     IF (Identifier='SHOWMEM') AND (Value='TRUE') Then DoMem := True;
  111.    End;
  112.   End;
  113.  End;
  114.  { Test user options }
  115.  If Timeout<1 Then Timeout := 1;
  116.  { Open archiver object }
  117.  PCode := Upper(ParamStr(1))+' ';
  118.  Case PCode[1] Of
  119.   'A':  New (A,Init(ParamStr(2),fWrite,InfoLogfn,ErrLogfn,DoReset,DoErase,DoMem));
  120.   'X','L':  New (A,Init(ParamStr(2),fRead,InfoLogfn,ErrLogfn,DoReset,DoErase,DoMem));
  121.   Else
  122.    Exit;
  123.  End;
  124.  { Set options }
  125.  A^.Timeout := Timeout;
  126.  A^.Wordy := Wordy;
  127.  A^.DoTime := DoTime;
  128.  A^.SetTapeSize (TapeType);
  129.  A^.LongItemFlag := LongFlag;
  130.  { Action }
  131.  Case PCode[1] Of
  132.   'A': A^.AddFiles(ParamStr(3));
  133.   'X': A^.ExtractFiles(ParamStr(3));
  134.   'L': Begin
  135.         A^.DisplayFlag := True;
  136.         A^.ExtractFiles(ParamStr(3));
  137.        End;
  138.  End;
  139.  { Close Archiver object }
  140.  Dispose (A,Done);
  141. End.
  142.  
  143.